home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10880 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  37 lines

  1. Path: netnews.whoi.edu!NewsWatcher!user
  2. From: davef@mbl.edu (Dave Fernandes)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: [Q] how declare a Template class as a friend
  5. Date: Mon, 11 Mar 1996 11:04:16 -0500
  6. Organization: Marine Biological Laboratory
  7. Message-ID: <davef-1103961104160001@128.128.173.90>
  8. References: <Dnx660.1Ex@news.uwindsor.ca>
  9. NNTP-Posting-Host: 128.128.173.90
  10.  
  11. In article <Dnx660.1Ex@news.uwindsor.ca>, saed@engn.uwindsor.ca wrote:
  12.  
  13. > Hi all,
  14. > --- How do you declare a template class to be a friend of
  15. >     another non-template class?
  16. > template <class T> class A {};  // the template class A<T's>
  17. > class B { friend class A };     // won't do it, A is not a class
  18. > template <class V> class B { friend class A<V> };       // B<V's> are
  19. not wanted
  20.  
  21. What if you declare your template class A as a subclass of some other
  22. abstract class C, and have C be a friend of B?
  23.  
  24. class C {};
  25. template <class T> class A : public C {};
  26. class B {friend class C};
  27.  
  28. I'm not sure, but I think this should work.
  29.  
  30. -- 
  31. Dave Fernandes
  32. Postdoctoral Research Associate
  33. The Ecosystems Center
  34. Marine Biological Laboratory
  35.